package com.tencent.sr.iris.activity.interfaces.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.tencent.sr.rmall.common.exception.TMallBizException;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum AwardTypeEnum {

    REGISTER_REWARD("REGISTER_REWARD", "注册有礼"),
    INVITE_NEW_REWARD("INVITE_NEW_REWARD", "邀请有礼"),
    INVITE_GIFT("INVITE_GIFT", "邀请有礼"),
    LEVEL_UP_FOSTER_GIFT("LEVEL_UP_FOSTER_GIFT", "升级有礼(培育奖)"),
    LEVEL_UP_PROMO_GIFT("LEVEL_UP_PROMO_GIFT", "升级有礼(晋升奖)"),
    ;

    @JsonValue
    private final String code;
    private final String desc;

    @JsonCreator
    public static AwardTypeEnum getByCode(String code) {
        for (AwardTypeEnum staff : AwardTypeEnum.values()) {
            if (staff.getCode().equals(code)) {
                return staff;
            }
        }

        throw new TMallBizException("权益类型错误！");
    }
}
